package day20180129.designMode.five_Singleton;

/**
 * Created by 14394 on 2018/1/29.
 */

//单例模式,只适用于单线程
public class Singleton {
    private static Singleton singleton = new Singleton();

    private Singleton(){  //private禁止从Singleton类外部调用构造函数，确保只生成一个实例
        System.out.println("生成了一个实例。");
    }

    public static Singleton getInstance(){
        return singleton;
    }
}
